<template>
  <div class="collapse-com">
    <el-collapse v-model="activeName" accordion>
      <el-collapse-item :name="item.busId" v-for="item in collapseData" :key="item.busId">
        <template slot="title">
          <div class="item-title">{{ item.assessName }}</div>
          <div class="item-desc" v-if="item.assessDesc">（{{ item.assessDesc }}）</div>
        </template>
        <template v-if="item.children && item.children.length">
          <CollapseComponent :collapseData="item.children"></CollapseComponent>
        </template>
        <template v-if="item.optionList && item.optionList.length">
          <div class="option-box">
            <div class="option-item" v-for="item in item.optionList" :key="item.optionId">
              <div class="option-name">
                <span class="name">{{ item.optionLabel }}</span>
                <span class="score">（{{ item.optionScore }}）</span>
              </div>
              <div class="option-desc">{{ item.optionContent }}</div>
            </div>
          </div>
        </template>
      </el-collapse-item>
    </el-collapse>
  </div>
</template>

<script>
export default {
  name: 'CollapseComponent',
  components: {},
  props: {
    collapseData: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      activeName: '',
    }
  },
  watch: {
    collapseData: {
      handler(news) {
        if (news.length) {
          this.activeName = news[0].busId
        }
      },
      deep: true,
      immediate: true,
    },
  },
  computed: {},
  created() {},
  mounted() {},
  methods: {},
}
</script>
<style lang="scss" scoped>
.collapse-com {
  /deep/.el-collapse {
    .item-title {
      font-weight: bold;
      font-size: 15px;
    }
    .el-collapse-item__header {
      height: 40px;
      line-height: 40px;
      font-size: 14px;
    }
    .el-collapse-item__content {
      padding: 10px 12px 5px;
      padding-top: 0;
      font-size: 14px;
    }
    .option-box {
      .option-item {
        display: flex;
        align-items: stretch;
        line-height: 1.6;
        border: 1px solid #ccc;
        &:not(:last-of-type) {
          border-bottom: 0;
        }
        .option-name {
          width: 80px;
          min-width: 80px;
          text-align: center;
          border-right: 1px solid #ccc;
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: center;
          padding: 5px;
          line-height: 1.2;
        }
        .option-desc {
          padding: 5px;
          display: flex;
          align-items: center;
        }
      }
    }
    .el-collapse {
      .item-title {
        font-weight: bold;
        font-size: 15px;
      }
    }
  }
}
</style>
